<?php
namespace Admin\Controller;
use Think\Controller;
class NavController extends CommonController {
    public function lists(){
        $nav=D('nav');
        $list=$nav->select();
        $this->assign('list',$list);
        $this->display();
    }
    public function add(){
        if(IS_POST){
           //$_POST['icon'].=' white';
            $nav=D('nav');
            $result=$nav->add(I('post.'));
            if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER']
            $this->success('新增成功', 'lists');die;
            }else{    //错误页面的默认跳转页面是返回前一页，通常不需要设置
                $this->error('新增失败');
            }die;
        }
        $nav=D('nav');
        $list=$nav->where('pid=0')->select();
        $this->assign('list',$list);
        $this->display();
    }
}